#ifndef MEMORY_H
#define MEMORY_H

#include <QObject>
#include <QMap>
#include <QString>


class Memory : public QObject
{
    Q_OBJECT

public:
    virtual ~Memory();
    //
    void write(quint32 address, const QString& content);
    QString read(quint32 address) const;
    //
    static Memory* getInstance(QObject* parent = 0);

private:
    Memory(QObject *parent = 0);
    //
    QString readMemoryMapping(quint32 address) const;
    void writeMemoryMapping(quint32 address, const QString& value);
    bool isSpecialAddress(quint32 address) const;

private:
    QMap<quint32, QString> memory;
    //
    static Memory* instance;
    //
    static bool ok;
    static const quint32 KBSR_ADDRESS;
    static const quint32 KBDR_ADDRESS;
    static const quint32 DSR_ADDRESS;
    static const quint32 DDR_ADDRESS;
    static const quint32 MCR_ADDRESS;

signals:
    void dataChanged(quint32 address);

};

#endif // MEMORY_H
